package starter.proto;

import static com.bowlong.net.proto.gen3.B3G.CLASSIFY_WRITE;
import static com.bowlong.net.proto.gen3.B3G.DATA;
import static com.bowlong.net.proto.gen3.B3G.SERVER;

import java.util.List;

import com.bowlong.io.FileEx;
import com.bowlong.net.proto.gen3.B3Class;
import com.bowlong.net.proto.gen3.B3Field;
import com.bowlong.net.proto.gen3.B3G;
import com.bowlong.net.proto.gen3.B3Method;
import com.bowlong.net.proto.gen3.B3Param;
import com.bowlong.net.proto.gen3.Bio3GCSharp;
import com.bowlong.net.proto.gen3.Bio3GCSharpCmd;
import com.bowlong.net.proto.gen3.Bio3GCSharpNative;
import com.bowlong.net.proto.gen3.Bio3GJava;

/**
 * 客户端通信接口
 */
@B3Class(namespace = "game")
public class GameService {
	public static void main(String[] args) throws Exception {
		Class<?> c = GameService.class;
		boolean src = FileEx.exists("src");
		Bio3GJava.b2g(c, src);
		Bio3GCSharp.b2g(c, src);
		Bio3GCSharpNative.b2g(c, src);
		Bio3GCSharpCmd.b2g(c, src);
		// {
		// String oldPath =
		// "/Users/zhangrenzhi/Documents/workspace.sojoys/coh.core/src/gen_B3G/game/GameService.cs";
		// String newPath =
		// "/Users/zhangrenzhi/Documents/Unity/coh/Assets/Scripts/Net/GameService.cs";
		// MacExec.copyFile(oldPath, newPath);
		// }
		// {
		// String oldPath =
		// "/Users/zhangrenzhi/Documents/workspace.sojoys/coh.core/src/gen_B3G/game/CmdGameServiceI.cs";
		// String newPath =
		// "/Users/zhangrenzhi/Documents/Unity/coh/Assets/Scripts/Net/CmdGameServiceI.cs";
		// MacExec.copyFile(oldPath, newPath);
		// }
		// {
		// String oldPath =
		// "/Users/zhangrenzhi/Documents/workspace.sojoys/coh.core/src/gen_B3G/game/CallNativeGameService.cs";
		// String newPath =
		// "/Users/zhangrenzhi/Documents/Unity/coh/Assets/Scripts/Net/CallNativeGameService.cs";
		// MacExec.copyFile(oldPath, newPath);
		// }
	}

	// ///////////////////////////////////////////////////

	@B3Class(type = DATA, remark = "int")
	class NInt {
		int v;
	}

	@B3Class(type = DATA, remark = "str")
	class NStr {
		String v;
	}

	@B3Class(type = DATA, remark = "bool")
	class NBool {
		boolean v;
	}

	@B3Class(type = DATA, remark = "list")
	class NIntList {
		List<Integer> vals;
	}

	@B3Class(type = DATA, remark = "id or key")
	class NIdOrKey {
		int id;
		int key;
	}

	@B3Class(type = DATA, remark = "id or key")
	class NIdOrKeys {
		List<NIdOrKey> idOrKeys;
	}

	@B3Class(type = DATA, remark = "返回值")
	class ReturnStatus {
		int succ;
		String msg;
	}

	@B3Class(type = B3G.DATA, remark = "类型定义", constant = true)
	class GType {
		// 用户类型
		@B3Field(remark = "", def = "user")
		String UserType_Player;

		@B3Field(remark = "", def = "npc")
		String UserType_Npc;

		@B3Field(remark = "", def = "gm")
		String UserType_GM;
	}

	@B3Class(type = B3G.DATA, remark = "消息类型", constant = true)
	class SuccType {
		@B3Field(remark = "成功", def = "0")
		int TRUE;
		// --------异常信息(具有文字对应)
		@B3Field(remark = "服务器异常信息", def = "-1")
		int Error;
		@B3Field(remark = "离线", def = "-2")
		int OFFLINE;
		@B3Field(remark = "提示信息", def = "-3")
		int ALERT;
	}

	@B3Class(type = B3G.DATA, remark = "渠道", constant = true)
	class ChannelType {
		@B3Field(remark = "系统", def = "system")
		String SYSTEM;
		@B3Field(remark = "安卓.360", def = "android.360")
		String Android360;
		@B3Field(remark = "安卓.91", def = "android.91")
		String Android91;
		@B3Field(remark = "安卓.移动cm", def = "android.cm")
		String AndroidCm;
		@B3Field(remark = "安卓.当乐", def = "android.d")
		String AndroidDJoys;
		@B3Field(remark = "安卓.机锋", def = "android.gfan")
		String AndroidGFan;
		@B3Field(remark = "安卓.机锋", def = "android.google")
		String AndroidGoogle;
		@B3Field(remark = "安卓.小米", def = "android.mi")
		String AndroidMi;
		@B3Field(remark = "安卓.移动mm", def = "android.mm")
		String AndroidMm;
		@B3Field(remark = "安卓.uc", def = "android.uc")
		String AndroidUc;
		// //////
		@B3Field(remark = "ios 25pp", def = "ios.25pp")
		String Ios25pp;
		@B3Field(remark = "ios 91", def = "ios.91")
		String Ios91;
		@B3Field(remark = "ios apple", def = "ios.apple")
		String IosApple;
		@B3Field(remark = "ios uc", def = "ios.uc")
		String IosUc;
		// //////
		@B3Field(remark = "sojoys", def = "sojoys")
		String Sojoys;
		@B3Field(remark = "无", def = "none")
		String NONE;
	}

	// --------------------------网络传输对象------------------------
	@B3Class(type = DATA, remark = "用户对象")
	class NUser {
		int id;
	}

	/**
	 * @info 4.同步消息系统未测试
	 */
	@B3Class(type = SERVER)
	interface GameServiceI {
		// ///////////////////////////////服务器端实现///////////////////////////////////
		@B3Method(type = SERVER, params = { "str", "rst2" }, remark = "ping")
		ReturnStatus ping(String str, @B3Param(isOut = true) NStr rst2);

		/** -------------- 用户操作 -------------- */
		@B3Method(type = SERVER, params = { "token", "device", "deviceSystem",
				"deviceCode", "resolution", "language", "uuid", "pass",
				"version", "channel", "serverId", "loginType", "nUser" }, classify = CLASSIFY_WRITE, remark = "登陆")
		ReturnStatus login(String token, String device,
				String deviceSystem,
				String deviceCode,
				String resolution, // 分辨率
				String language, String uuid, String pass, String version,
				String channel, int serverId, int loginType,
				@B3Param(isOut = true) NUser nUser);

		@B3Method(type = SERVER, params = { "index" }, remark = "提交新手任务步奏")
		ReturnStatus submitNewTaskIndex(int index);

		@B3Method(type = SERVER, params = { "name", "pass" }, remark = "设置昵称密码")
		ReturnStatus setNameAndPass(String name, String pass);

	}

	// ///////////////////////////////////////////////////

}
